function comment_submit(oform) {
	var check_validate_code_response = function(oXML) {
		if(oXML == 'ok') {
			var comment_response = function(oXML) {
				if(oXML == 'ok') {
					// 评论成功
					oform.elements['nickname'].value = '';
					oform.elements['anonymous'].checked = false;
					oform.elements['comment_content'].value = '';
					reload_validate_code('#validate_img', 70, 21);
					$('#validate_code').attr({ value: ''});
					alert('评论成功');
					comment_list(aid, 1, pagesize)
				} else {
				}
			}

			var nickname = oform.elements['nickname'].value;
			var anonymous = oform.elements['anonymous'].checked;
			var comment_content = oform.elements['comment_content'].value;
			var aid = oform.elements['aid'].value;

			if(!anonymous && nickname == '') {
				alert('请输入您的昵称！');
				oform.elements['nickname'].focus();
				return false;
			}

			if(comment_content == '') {
				alert('评论不能为空！');
				oform.elements['comment_content'].focus();
				return false;
			}
			param = '&aid=' + aid;
			if(anonymous) param += '&anonymous=' + 1;
			param += '&nickname=' + nickname + '&comment_content=' + comment_content;
			url = commenturl + '?action=add';
			$.post(url, param, comment_response);
		} else {
			reload_validate_code('#validate_img', 70, 21);
			$('#validate_code').attr({ value: ''});
		}
	}
	code = oform.elements['validate_code'].value;
	url = codeurl + '?action=query&code=' + code + '&front=1';
	var param = '';
	$.post(url, param, check_validate_code_response);
	return false;
}

function param_list(cid) {
	var param_list_response = function(oXML) {
		$("#param_html").html(oXML);
	}
	param = '';
	url = param_ajaxurl + '?action=paramli&cid=' + cid;
	$.post(url, param, param_list_response);
}

function param_add(cid) {
	var param_add_response = function(oXML) {
		if('error' == oXML) {
			alert('添加参数错误！');
		} else if('samename' == oXML) {
			alert('当前分类中已存在名为“'+paramname+'”的参数！');
		}else {
			$("#param_html").html(oXML);
		}
	}

	var paramname   = $("#param_add_paramname").val();
	var paramorder  = $("#param_add_paramorder").val();
	var paramtype   = parseInt($("#param_add_paramtype").val());
	var defvalue    = $("#param_add_defvalue").val();
	var clos        = parseInt($("#param_add_clos").val());
	var rows        = parseInt($("#param_add_rows").val());
	if(paramname == '') {
		alert('参数名称必须填写！');
		return false;
	}

	if(isNaN(paramtype)) paramtype = 0;
	if(isNaN(paramorder) || paramorder <= 0) paramorder = 2147483647;
	if(isNaN(clos) || clos <=0) clos = 30;
	if(isNaN(rows) || rows <=0) rows = 8;

	param  = '';
	param += '&paramname=' + paramname + '';
	param += '&paramorder=' + paramorder + '';
	param += '&paramtype=' + paramtype + '';
	param += '&defvalue=' + defvalue + '';
	param += '&clos=' + clos + '';
	param += '&rows=' + rows + '';

	url = param_ajaxurl + '?action=paramadd&cid=' + cid;
	$.post(url, param, param_add_response);
	return false;
}

function param_modify(id) {
	var param_modify_response = function(oXML) {
		if('error' == oXML) {
			alert('修改参数错误！');
		} else if('samename' == oXML) {
			alert('当前分类中已存在名为“'+paramname+'”的参数！');
		}else {
			$("#param_html").html(oXML);
		}
	}


	var paramname   = $("#param_"+id+"_paramname").val();
	var paramorder  = $("#param_"+id+"_paramorder").val();
	var paramtype   = parseInt($("#param_"+id+"_paramtype").val());
	var defvalue    = $("#param_"+id+"_defvalue").val();
	var clos        = parseInt($("#param_"+id+"_clos").val());
	var rows        = parseInt($("#param_"+id+"_rows").val());
	if(paramname == '') {
		alert('参数名称必须填写！');
		return false;
	}

	if(isNaN(paramtype)) paramtype = 0;
	if(isNaN(paramorder) || paramorder <= 0) paramorder = 2147483647;
	if(isNaN(clos) || clos <=0) clos = 30;
	if(isNaN(rows) || rows <=0) rows = 8;

	param  = '';
	param += '&id=' + id + '';
	param += '&paramname=' + paramname + '';
	param += '&paramorder=' + paramorder + '';
	param += '&paramtype=' + paramtype + '';
	param += '&defvalue=' + defvalue + '';
	param += '&clos=' + clos + '';
	param += '&rows=' + rows + '';

	url = param_ajaxurl + '?action=parammodify';
	$.post(url, param, param_modify_response);
	return false;
}

function param_del(id) {
	var param_modify_response = function(oXML) {
		if('error' == oXML) {
			alert('删除参数错误！');
		}else{
			$("#param_html").html(oXML);
		}
	}

	param  = '';
	param += '&id=' + id + '';

	url = param_ajaxurl + '?action=paramdel';
	$.post(url, param, param_modify_response);
	return false;
}

function articleparam_list(cid, aid) {
	var articleparam_list_response = function(oXML) {
		$("#param_html").html(oXML);
	}
	cid = parseInt(cid);
	aid = parseInt(aid);
	if(isNaN(cid)) return false;
	if(isNaN(aid)) aid = 0;

	param = '';
	url = param_ajaxurl + '?action=articleparamlist&cid=' + cid + '&aid=' + aid;
	$.post(url, param, articleparam_list_response);
}




